package main

import (
	"fmt"
	"net"
)

func main() {
	c := make(chan struct{})
	addr, err := net.ResolveTCPAddr("tcp", ":8088")
	if err != nil {
		panic(err)
	}
	tl, err := net.ListenTCP("tcp", addr)
	if err != nil {
		panic(err)
	}

	tcpConn, err := tl.AcceptTCP()
	if err != nil {
		panic(err)
	}

	err = tcpConn.SetReadBuffer(4)
	if err != nil {
		panic(err)
	}

	go handleConn(tcpConn)

	<-c

}

func handleConn(conn *net.TCPConn) {

	bytes := make([]byte, 4)
	read, err := conn.Read(bytes)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(bytes[:read]))

}
